const mongoose = require('mongoose');

const outboundOrderSchema = new mongoose.Schema({
  productId: { 
    type: mongoose.Schema.Types.ObjectId, 
    ref: 'Product', 
    required: true 
  },
  productName: { type: String, required: true }, // 冗余存储方便查询
  outboundTime: { type: Date, required: true, default: Date.now },
  quantity: { type: Number, required: true, min: 1 },
  userName: { type: String, required: true },
  phone: { type: String, required: true },
  address: { type: String, required: true },
  status: { 
    type: String, 
    enum: ['待审核', '待发货审核', '已发货', '审核不通过'],  // 修改：待发货 → 待发货审核
    default: '待审核' 
  }
}, { timestamps: true });

module.exports = mongoose.model('OutboundOrder', outboundOrderSchema);